/ Assembly List / LJCDBClientLib / DataManager / Retrieve

Namespace - LJCDBClientLib


Parameters
keyColumns - The record containing the key field values.
propertyNames - The incuded column property names.
filters - The filter values.
joins - The join values.

Returns

The result object.

Syntax

C#
public DbResult Retrieve(DbColumns keyColumns, List<String> propertyNames = null, DbFilters filters = null, DbJoins joins = null)

Retrieves a record from the database. (DE)

Remarks

Parameters

keyColumns
This parameter defines the values to be used in the SQL where clause. It is only used if the 'filters' parameter is null.
The values are separated with the 'AND' operator.

propertyNames
This parameter defines the primary table columns that are to be included in the request. If it is null, then all the primary table columns are included.
It must not include Calculated or Join columns or it will cause an error.

filters
This parameter defines the values to be used in the SQL where clause. If it is defined, then the keyColumns parameter is not used.
The 'filters' object can define a complex where clause including combinations of 'AND' and 'OR' operators.

joins
The 'joins' parameter defines the join tables, join on values and join column definitions.

Creates a "Select" DbRequest object, which is available in the Request property. The request object is passed to the ExecuteRequest() method.

Request Column property names and values are added to the Result Value columns.

The Result Data Object property names must match the Result Value Column property names to map the values into the Result Data Object.

Result Data Object property names that are different from the Request Column names can be handled by setting the Request Column Property name. The MapNames() method is a helper method for setting the Property name.

Method Graph

All methods are in LJCDBMessage.DbCommon.

ResultColumns(baseDefinition)
ResultKeys(keyColumns)
CreateKeyColumn(keyColumn)

Example

C#
// This is an example of the code to use the Person Manager Retrieve()
// method.
PersonManager personManager = new PersonManager();
Person personKey = new Person()
{
  PersonId = 1
};
Person person = personManager.Retrieve(personKey);

// This is an example of the Person Manager code that would access the
// DataManager Retrieve() method. The supporting class code is listed at
// the DataManager class level.

using LJCNetCommon;
using LJCDBMessage;

/// <summary>Provides Person specific data manipulation methods.</summary>
public class PersonManager
{
  /// <summary>Retrieves a person record from the database.</summary>
  /// <param name="keyObject">The record containing the key field values.</param>
  /// <param name="propertyNames">The incuded column property names.</param>
  /// <param name="filters">The filter values.</param>
  /// <param name="dbJoins">The join values.</param>
  /// <returns>A person object.</returns>
  public Person Retrieve(Person keyObject, List<string> propertyNames = null
    , DbFilters filters = null, DbJoins dbJoins = null)
  {
    Person retValue = null;
    
    DbResult dbResult = mDataManager.Retrieve(keyObject, propertyNames, filters, dbJoins);
    SQLStatement = mDataManager.SQLStatement;
    if (dbResult != null && dbResult.DbRecords.Count > 0)
    {
      // Populate a data object with the result values.
      retValue = new Person();
      DbCommon.SetObjectValues(dbResult.DbRecords[0], retValue);
    }
    return retValue;
  }
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.